package com.ruoyi.question.domain;

import com.ruoyi.common.enums.QuestionTypeEnum;
import com.ruoyi.common.utils.ExamUtil;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

import java.util.List;

/**
 * 题目信息对象 t_question
 * 
 * @author ruoyi
 * @date 2023-06-23
 */
public class Question extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键 */
    private Long id;

    /** 题目类型 */
    @Excel(name = "题目类型")
    private Long questionType;

    /** 题目总分 */
    @Excel(name = "题目总分")
    private Long score;

    /** 题目  填空、 题干、解析、答案等信息关联表ID */
    @Excel(name = "题目  填空、 题干、解析、答案等信息关联表ID")
    private Long textContentId;

    /** 正确答案 */
    private String correct;

    /** 是否删除 */
    private Long deleted;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setQuestionType(Long questionType) 
    {
        this.questionType = questionType;
    }

    public Long getQuestionType() 
    {
        return questionType;
    }
    public void setScore(Long score) 
    {
        this.score = score;
    }

    public Long getScore() 
    {
        return score;
    }
    public void setTextContentId(Long textContentId) 
    {
        this.textContentId = textContentId;
    }

    public Long getTextContentId() 
    {
        return textContentId;
    }
    public void setCorrect(String correct) 
    {
        this.correct = correct;
    }

    public String getCorrect() 
    {
        return correct;
    }
    public void setDeleted(Long deleted) 
    {
        this.deleted = deleted;
    }

    public Long getDeleted() 
    {
        return deleted;
    }


    public void setCorrectFromVM(String correct, List<String> correctArray) {
        Long qType = this.getQuestionType();
        if (qType == QuestionTypeEnum.MultipleChoice.getCode()) {
            String correctJoin = ExamUtil.contentToString(correctArray);
            this.setCorrect(correctJoin);
        } else {
            this.setCorrect(correct);
        }
    }
}
